#include <stdio.h>
#include <linux/input.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

//find from:/proc/bus/input/devices or /dev/input/*
#define KB_INPUT_EVENT_PATH "/dev/input/event3"

int main(void)
{
	int fd = 0;
	struct input_event ev;
	ev.type = EV_LED;

	fd = open(KB_INPUT_EVENT_PATH, O_RDWR);
	if (fd < 0) {
		printf("Open keyboard input event file failed!\n");
		return 1;
	}

	while(1) {
		ev.code = LED_NUML;
		ev.value = 1;
		write(fd, &ev, sizeof(ev));
		ev.code = LED_CAPSL;
		write(fd, &ev, sizeof(ev));
		ev.code = LED_SCROLLL;
		write(fd, &ev, sizeof(ev));
		sleep(1);
		ev.value = 0;
		write(fd, &ev, sizeof(ev));
		ev.code = LED_CAPSL;
		write(fd, &ev, sizeof(ev));
		ev.code = LED_NUML;
		write(fd, &ev, sizeof(ev));
		sleep(1);
	}

	return 0;
}
